<template>
  <div></div>
</template>

<script>
export default {
  props: {},
  components: {},
  data() {
    return {
      user: null,
      phone: null,
      myData: {
        name: "张三",
        age: 25,
        address: "北京市",
      },
    };
  },
  computed: {},
  watch: {
    user: {
      handler: function (val) {
        console.log(val);
      },
      deep: true,
    },
    phone: {
      handler: function (val) {
        console.log(val);
        console.log("hahahasasafsafas1111");
      },
    },
  },
  created() {},
  mounted() {},
  methods: {
  
    getNum(val) {
      console.log(val);
    },
    changeMydata() {
    
    },
    // 写一个节流的方法
    throttle(func, wait) {
      let timer = null;
      return function () {
        if (!timer) {
          timer = setTimeout(() => {
            func.apply(this, arguments);
            timer = null;
          }, wait);
        }
      };
    },
    // 写一个防抖的方法
    debounce(func, wait) {
      let timer = null;
      return function () {
        if (timer) {
          clearTimeout(timer);
        }
        timer = setTimeout(() => {
          func.apply(this, arguments);
        }, wait);
      };
    },
  },
};
</script>

<style scoped lang="less"></style>
